<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>上传图片</title>
    <style>
        .section {
            margin-bottom: 32px;
            padding: 24px;
            border: 1px solid #eee;
            border-radius: 8px;
        }
        .success{
            color:green;
        }
        .error{
            color:red;
        }
        .result-img{
            width:100px;
        }
    </style>
</head>
<body>
    <h1>上传图片</h1>
    <a href="{{ url_for('home') }}" style="display:inline-block;margin-bottom:20px;">返回首页</a>
    <div class="section">
        <form method="post" enctype="multipart/form-data" action="{{ url_for('search_image') }}">
          <input type="file" name="file" accept=".jpg,.jpeg,.png,.gif">
          <button type="submit">检索</button>
        </form>
    </div>
    <h2>检索结果</h2>
    <ul>
        {% for item in results%}
            <li>
                <p>图片:<img class="result-img" src="{{item['image_url']}}"/></p>
                <p>相似度:{{'%.4f'|format(item["score"])}}</p>
            </li>
        {% endfor %}
    </ul>
    {% with messages = get_flashed_messages(with_categories=true) %}
        {%  if messages %}
            <ul class="flashes">
                {% for category, message in messages %}
                    <li class="flash {{category}}">{{ message }}</li>
                {% endfor %}
            </ul>
        {% endif %}
    {% endwith %}
</body>
</html>